<script >
import {computed, defineComponent, ref} from "vue";

export default defineComponent({
    name: 'SvgIcon',
    props: {
        icon: {
            type: [String, Object],
        },
        prefix: {
            type: String,
            default: 'icon'
        }
    },
    setup(props) {
        const com = computed(() => typeof props.icon === 'object' || props.icon?.indexOf('el-icon-') === 0);
        return {
            com
        };
    }
})

</script>

<template>
    <component v-if="com" :is="icon"/>
    <svg v-else aria-hidden="true">
        <use :xlink:href="`#${icon?.indexOf('icon-') === 0? icon:prefix + '-' + icon}`"/>
    </svg>
</template>
